package com.zhongjianjian.redisLock.dao;

import com.zhongjianjian.redisLock.entity.TestStock;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;
import java.util.Map;

/**
 * 作者: LCG
 * 日期: 2020/2/21 20:12
 * 描述:
 */
@Mapper
public interface StockDao {

    @Select("select * from base_stock where goods_id=#{goodsId}")
    @Results( value = {
       @Result(property = "goodsId",column = "goods_id",jdbcType = JdbcType.BIGINT),
       @Result(property = "stock",column = "stock",jdbcType = JdbcType.INTEGER),
       @Result(property = "createDate",column = "create_time",jdbcType = JdbcType.DATE)
     }
    )
    public TestStock getStock(Map<String, String> param);

    /**
     * 更新库存
     * @param testStock
     * @return
     */
    @Update("update base_stock set stock=#{stock} where goods_id=#{goodsId}")
    public int updateStock(TestStock testStock);

}
